Replace std::mutex with DefaultUnnamedMutex to avoid named mutex exhaustion#950
Open
Replace std::mutex with DefaultUnnamedMutex to avoid named mutex exhaustion#950
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces a custom mutex class,
DefaultUnnamedMutex, to work around a platform STL defect wherestd::mutexdefault construction creates named mutexes — which have a low system-wide limit. The new class ensures mutexes are unnamed by default, preventing handle exhaustion under heavy concurrency. Allstd::mutexusages are replaced withDefaultUnnamedMutexthroughout the codebase.STL mutex workaround:
DefaultUnnamedMutexclass inpal.hto replacestd::mutexand avoid named mutexes. (Include/httpClient/pal.hInclude/httpClient/pal.hR498-R515)std::mutexto useDefaultUnnamedMutexin key classes and structures, including:NetworkState(Source/Global/NetworkState.hSource/Global/NetworkState.hL79-R79)http_singleton::singleton_access(Source/Global/global.cppSource/Global/global.cppL28-R32)AsyncState(Source/Task/AsyncLib.cppSource/Task/AsyncLib.cppL48-R48)AtomicVector(Source/Task/AtomicVector.hSource/Task/AtomicVector.hL97-R97)SubmitCallback,QueueWaitRegistry,TaskQueuePortImpl,TaskQueueImpl(Source/Task/TaskQueueImpl.h[1] [2] [3] [4]ThreadPool_stl.cppandWaitTimer_stl.cppmutexes (Source/Task/ThreadPool_stl.cpp[1]Source/Task/WaitTimer_stl.cpp[2] [3]WebSocketstate mutex (Source/WebSocket/hcwebsocket.hSource/WebSocket/hcwebsocket.hL184-R184)General codebase update for thread safety:
DefaultUnnamedMutexfor consistent behavior across platforms. [1] [2]Header and dependency updates:
<mutex>inpal.hto support the new mutex class. (Include/httpClient/pal.hInclude/httpClient/pal.hR16)